user_data = {
    'aa':{'password':'123', '余额':8888},
    'bb':{'password':'123', '余额':9999},
    'cc':{'password':'123', '余额':10},
    'dd':{'password':'123', '余额':500},
}
while True:
    print('='*10, 'ATM系统', '='*10)
    print("  请登录：")
    user: str = input("请输入您的账号：")
    if user in user_data:
        # 输入账号是否存在
        passwd = input("请输入密码：")
        if passwd == user_data[user]['password']:
            # 判断密码是否正确
            while True:
                print('{0:1} {1:10} {2:10}'.format(' ', '1. 查询余额', '2. 取钱'))
                print('{0:1} {1:10} {2:10}'.format(' ', '3. 存钱', '4. 退出系统'))
                key = input("请选择您要进行的业务：")
                if key == '1':
                    print('卡上余额为：' + str(user_data[user]['余额']))
                elif key == '2':
                    saves = input('要取多少钱：')
                    if int(saves) > int(user_data[user]['余额']):
                        print("余额不足！")
                    else:    # 先将字典中原先的‘余额’删除，再重新添加
                        saves = int(user_data[user]['余额']) - int(saves)
                        del user_data[user]['余额']
                        user_data[user]['余额'] = saves
                        print('取款成功，现在余额为：' + str(user_data[user]['余额']))
                elif key == '3':
                    saves = input('要存多少钱：')
                    saves = int(saves) + int(user_data[user]['余额'])
                    del user_data[user]['余额']
                    user_data[user]['余额'] = saves
                    print('存入成功，现在余额为：' + str(user_data[user]['余额']))
                elif key == '4':
                    print('欢迎下次光临!')
                    break
                else:
                    print('输入不合法！')
        else:
            print('密码错误!')
    else:
        print('账户不存在！')